package com.beanu.sh;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.telephony.PhoneNumberUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class SmsHelper extends Activity {
	
	Button button;
	EditText phonenumber;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        button=(Button)findViewById(R.id.button_id);
		button.setOnClickListener(allOnClickListener);
        
		phonenumber=(EditText)findViewById(R.id.phonenumber);
		
		
    }
    OnClickListener allOnClickListener=new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			if(v==button){
				String sphonenumber=phonenumber.getText().toString();
				if(PhoneNumberUtils.isGlobalPhoneNumber(sphonenumber)){
					Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse("tel://"+sphonenumber));
					startActivity(i);
				}else{
					Toast.makeText(SmsHelper.this, R.string.notify_incorrect_phonenumber, Toast.LENGTH_LONG).show();
				}
			}
			
		}
	};
    
}